package ${packageName}.controller;

import ${packageName}.entity.${entityName};
import ${packageName}.service.I${entityName}Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
* ${tableComment} 前端控制器
* @author ${author}
* @date ${date?string("yyyy-MM-dd")}
*/
@RestController
@RequestMapping("/${entityName?lower_case}") // 请求路径：/userinfo（小写实体名）
public class ${entityName}Controller {

@Resource // 注入Service
private I${entityName}Service ${entityName?uncap_first}Service;

/**
* 分页查询所有数据
*/
@GetMapping("/page")
public Page<${entityName}> page(
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize
) {
Page<${entityName}> page = new Page<>(pageNum, pageSize);
return ${entityName?uncap_first}Service.page(page); // MyBatis-Plus分页查询
}

    /**
    * 根据ID查询单条数据
    */
    @GetMapping("/{id}")
    public ${entityName} getById(@PathVariable("id") Long id) {
        return ${entityName?uncap_first}Service.getById(id);
    }

/**
* 新增数据
*/
@PostMapping
public boolean save(@RequestBody ${entityName} ${entityName?uncap_first}) {
return ${entityName?uncap_first}Service.save(${entityName?uncap_first});
}

/**
* 修改数据
*/
@PutMapping
public boolean update(@RequestBody ${entityName} ${entityName?uncap_first}) {
return ${entityName?uncap_first}Service.updateById(${entityName?uncap_first});
}

    /**
     * 根据ID删除数据
    */
    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable("id") Long id) {
        return ${entityName?uncap_first}Service.removeById(id);
    }

}